package coreservice

import (
	"core/coreentity"
	"core/corestruct"
)

type htUserRoleService struct {
}

func (p htUserRoleService) GetRoles(uids []int64, did int64, ctx *corestruct.HttpContext) ([]corestruct.IdNameAttrDto, error) {
	var r []corestruct.IdNameAttrDto
	var tx = ctx.DB.Model(&coreentity.HtUserRole{}).
		Select("role.id,role.name,HtUserRole.htuser_id as id1").
		Joins(" inner join HtRole role on HtUserRole.htuser_id in ? and HtUserRole.htdept_id=? and   HtUserRole.htrole_id=role.id and role.deleted=0", uids, did).
		Find(&r)
	if tx.Error != nil {
		return nil, tx.Error
	} else {
		return r, nil
	}
}

var (
	HtUserRoleservice = &htUserRoleService{}
)
